package com.alex.controller;

import cn.hutool.http.HttpUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.Map;

import static com.alex.controller.MainController.RESTURL_ES;

@Slf4j
@Tag(name = "R检索，详情有关")
@RestController
@RequestMapping("rsearch")
public class RSearchController {


    @GetMapping("/rpic")
    public String rpic(@RequestParam("uid") Integer uid, @RequestParam("uuid") String uuid) {
        log.info("uuid" + uuid);
        log.info("uid" + uid);
        String url = RESTURL_ES + "/rsearch/rpic";
        Map<String, Object> paramMap = new LinkedHashMap<>();
        paramMap.put("uuid", uuid);
        paramMap.put("uid", uid);
        String post = HttpUtil.get(url, paramMap);
        return post;
    }

    @SneakyThrows
    // 获取R语言结果
    @GetMapping("get-r-calculate-res")
    public String getSearchWosLocal(String keySearch) {
        String url = RESTURL_ES + "/rsearch/get-r-calculate-res?keySearch=" + keySearch;
        String post = HttpUtil.get(url);
        return post;
    }


    // @ApiOperation(value = "testConceptualstructuremap")
    @GetMapping("Conceptualstructuremap")
    public String newSearch(String reKey) {
        String url = RESTURL_ES + "/rsearch/Conceptualstructuremap?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;
    }

    // @ApiOperation(value = "FactorialMapOfTheDocumentsWithTheHighestContributes")
    @GetMapping("FactorialMapOfTheDocumentsWithTheHighestContributes")
    public String newSearch2(String reKey) {
        String url = RESTURL_ES + "/rsearch/FactorialMapOfTheDocumentsWithTheHighestContributes?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    // 新加几个功能测试图
    //@ApiOperation(value = "发文最多国家")
    @GetMapping("MostProdCountriesdf")
    public String MostProdCountriesdf(String reKey) {
        String url = RESTURL_ES + "/rsearch/MostProdCountriesdf?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    //@ApiOperation(value = "最多被引次数文章")
    @GetMapping("MostCitedPapersDATA")
    public String MostCitedPapersDATA(String reKey) {
        String url = RESTURL_ES + "/rsearch/MostCitedPapersDATA?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    //@ApiOperation(value = "期刊发文最多")
    @GetMapping("MostRelSourcesDATA")
    public String MostRelSourcesDATA(String reKey) {
        String url = RESTURL_ES + "/rsearch/MostRelSourcesDATA?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    //@ApiOperation(value = "国家发文被引排行榜")
    @GetMapping("TCperCountries")
    public String TCperCountries(String reKey) {
        String url = RESTURL_ES + "/rsearch/TCperCountries?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    //@ApiOperation(value = "年份发文图")
    @GetMapping("yeararticletrendTAB")
    public String yeararticletrendTAB(String reKey) {
        String url = RESTURL_ES + "/rsearch/yeararticletrendTAB?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    //@ApiOperation(value = "作者DE关键词发文")
    @GetMapping("AuthorKeywordsDE")
    public String AuthorKeywordsDE(String reKey) {
        String url = RESTURL_ES + "/rsearch/AuthorKeywordsDE?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    //@ApiOperation(value = "ID关键词发文")
    @GetMapping("KeywordsPlusID")
    public String KeywordsPlusID(String reKey) {
        String url = RESTURL_ES + "/rsearch/KeywordsPlusID?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    //@ApiOperation(value = "作者年份发文图")
    @GetMapping("authorProdOverTime")
    public String authorProdOverTime(String reKey) {
        String url = RESTURL_ES + "/rsearch/authorProdOverTime?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }


    // @ApiOperation(value = "期刊发文增长图")
    @GetMapping("sourceGrowth")
    public String sourceGrowth(String reKey) {
        String url = RESTURL_ES + "/rsearch/sourceGrowth?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

//    @ApiOperation(value = "作者合作网络")
//    @GetMapping("AUcollaboration")
//    public String AUcollaboration(String reKey) {
//        Object conceptualstructuremaps = rservice.AUcollaboration(reKey);
//        return new ResultBean<>(conceptualstructuremaps);
//    }

    //@ApiOperation(value = "ID关键词发文增长图")
    @GetMapping("idGrowth")
    public String idGrowth(String reKey) {
        String url = RESTURL_ES + "/rsearch/idGrowth?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }

    //@ApiOperation(value = "获取其他图结果返回map")
    @GetMapping("otherpic")
    public String otherpic(String reKey) {
        log.info("rekey++" + reKey);
        String url = RESTURL_ES + "/rsearch/otherpic?reKey=" + reKey;
        String s = HttpUtil.get(url);
        return s;

    }


}
